#ifndef SERVER_CONNECTION_H
#define SERVER_CONNECTION_H

#include <map>

#include "MsnConnection.h"

class SessionConnection;

class MsnMessenger;

class ServerConnection : public MsnConnection
{
	typedef void (ServerConnection::*Processor)(MsnCommandWrapper*);
	typedef std::map<wxString, Processor> ProcessorMap;

private:
	static ProcessorMap processorMap;
	static bool InitProcessorMap();

	MsnMessenger* messenger;

public:
    ServerConnection(MsnMessenger* mm);
    virtual ~ServerConnection();

public:
	//return transaction id
    int OpenSessionConnection();

protected:
    virtual void ConnectionOpened();
    virtual void ConnectionFailed();
    virtual void ConnectionClosed();
    virtual void ConnectionBroken();

    //virtual void ProcessCommand(const wxString& line);

	virtual void ProcessCommand(MsnCommandWrapper* cmdWrapper); 

	Processor FindProcessor(const wxString& cmdType);

    void ProcessVER(MsnCommandWrapper* wrapper);
    void ProcessCVR(MsnCommandWrapper* wrapper);
    void ProcessXFR(MsnCommandWrapper* wrapper);
    void ProcessFLN(MsnCommandWrapper* wrapper);
    void ProcessILN(MsnCommandWrapper* wrapper);
    void ProcessNLN(MsnCommandWrapper* wrapper);
    void ProcessLSG(MsnCommandWrapper* wrapper);
    void ProcessLST(MsnCommandWrapper* wrapper);
    void ProcessCHL(MsnCommandWrapper* wrapper);
    void ProcessCHG(MsnCommandWrapper* wrapper);
    void ProcessSYN(MsnCommandWrapper* wrapper);
    void ProcessPRP(MsnCommandWrapper* wrapper);

    void ProcessADC(MsnCommandWrapper* wrapper);
    void ProcessADG(MsnCommandWrapper* wrapper);
    void ProcessREM(MsnCommandWrapper* wrapper);
    void ProcessRMG(MsnCommandWrapper* wrapper);
    void ProcessREG(MsnCommandWrapper* wrapper);

    void ProcessRNG(MsnCommandWrapper* wrapper);

    void ProcessUSR(MsnCommandWrapper* wrapper);
    void ProcessMSG(MsnCommandWrapper* wrapper);

};


#endif

